package com.lyc.day1031.demo3;

/**
 * @author ：Xiaochen
 * @date ：Created in 2022/10/31 17:46
 * @description：
 * @modified By：
 * @version:
 */
public class Girl implements Runnable{
    private BackCard bankCard;
    public Girl(BackCard backCard){
        this.bankCard=backCard;
    }
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            if (bankCard.getBalance()>=1000) {
                bankCard.setBalance(bankCard.getBalance() - 1000);
                System.out.println(Thread.currentThread().getName() + "向卡中取出1000，卡中余额：" + bankCard.getBalance());
            }else {
                System.out.println("卡中余额不足");
                i--;
            }
        }
    }
}